#include <stdio.h>

int gcd( int m, int n );

int main()
{
    int x, y;

    scanf("%d %d", &x, &y);
    printf("%d\n", gcd(x, y));

    return 0;
}
int gcd( int m, int n )
{
	 int r,temp;
	 if(m<n)
	 {
	 	temp=m;
	 	m=n;
	 	n=temp;
	 }
	 r=m%n;
	 while(r!=0)
	 {
	 	m=n;
	 	n=r;
	 	r=m%n;
	 }
	 return n;
}
